package com.hongpu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hongpu.domain.HpProjectWorkPayListDetail;
import com.hongpu.dto.TotalContractAmountDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/**
* @author Michael zhang
* @description 针对表【hp_project_work_pay_list_detail(hp_project_work_pay_list表中支付数据的明细表)】的数据库操作Mapper
* @createDate 2025-05-08 13:57:50
* @Entity generator.domain.HpProjectWorkPayListDetail
*/
@Mapper
public interface HpProjectWorkPayListDetailMapper extends BaseMapper<HpProjectWorkPayListDetail> {

    /**
     * 根据 hpProjectWorkPayListId 查询 hp_project_work_pay_list_detail 中已支付总额paidTotal，排除id
     */
    public BigDecimal selectPaidTotalByHpProjectWorkPayListIdExcludeId(@Param("hpProjectWorkPayListId") Long hpProjectWorkPayListId,@Param("id") Long id);
    /**
     * 根据 hpProjectWorkPayListId 查询 hp_project_work_pay_list_detail 中已支付总额paidTotal，不排除id,但是需要排除已经被删除过的数据。
     */
    public  BigDecimal selectPaidTotalByHpProjectWorkPayListId(@Param("hpProjectWorkPayListId") Long hpProjectWorkPayListId);

    /**
     *  根据 hpProjectWorkPayListId 修改  hp_project_work_pay_list 中 paid 的值 paid = paidTotal + paid
     */
    public int updatePaidByHpProjectWorkPayListId(@Param("hpProjectWorkPayListId") Long hpProjectWorkPayListId,@Param("paid") BigDecimal paid);

    /**
     * 根据 hpProjectWorkPayListId 查询 hp_project_work_pay 中合同金额 totalContractAmount
     */
    public  BigDecimal selectTotalContractAmountByHpProjectWorkPayListId(@Param("hpProjectWorkPayListId") Long hpProjectWorkPayListId);
    /**
     * 根据 hpProjectWorkPayListId 修改  hp_project_work_pay_list 中 unpaid 的值 = totalContractAmount - paidTotal
     */
    public int updateUnpaidByHpProjectWorkPayListId(@Param("hpProjectWorkPayListId") Long hpProjectWorkPayListId,@Param("unpaid") BigDecimal unpaid);

    /**
     *  将数据修改为不需要开票，且开票信息全置空
     */
    public boolean updateNotInvoice(@Param("payListId") Long payListId);

    /**
     *  将数据修改为需要开票
     */
    public boolean updateInvoice(HpProjectWorkPayListDetail hpProjectWorkPayListDetail);
    /**
     * 根据详细数据ID修改数据
     * @param hpProjectWorkPayListDetail
     * @return
     */
    public boolean updateInvoiceInfoById(HpProjectWorkPayListDetail hpProjectWorkPayListDetail);
    /**
     * 修改单条 HpProjectWorkPayListDetail
     */
     public boolean updateOneHpProjectWorkPayListDetailData(HpProjectWorkPayListDetail hpProjectWorkPayListDetail);
     public boolean updateOneHpProjectWorkPayListDetailItHasBeenInvoiced(HpProjectWorkPayListDetail hpProjectWorkPayListDetail);


    /**
     * 根据 hp_project_work_pay_list_id 查询开票信息
     */
    public HpProjectWorkPayListDetail getInvoiceInfoByHpProjectWorkPayListId(Long hpProjectWorkPayListId);

    /**
     *  更新 hp_project_work_pay_list_detail 表中 it_has_been_invoiced 字段为 itHasBeenInvoiced
     */
    public boolean updateItHasBeenInvoiced(@Param("hpProjectWorkPayListId") Long hpProjectWorkPayListId,@Param("itHasBeenInvoiced") Integer itHasBeenInvoiced);

    /**
     * 根据 hp_project_work_pay_list_id 查询 hp_project_work_pay_list_detail 表中 it_has_been_invoiced
     */
     public Integer selectItHasBeenInvoicedByHpProjectWorkPayListId(@Param("hpProjectWorkPayListId") Long hpProjectWorkPayListId);

    /**
     * 更新合同金额
     */
    public boolean updateTotalContractAmount(@Param("hpProjectWorkPayListId") Long hpProjectWorkPayListId);

    /**
     *  根据 hpProjectWorkPayListId 统计所有支出合同金额
     */
    public TotalContractAmountDto getTotalContractAmount(Long hpProjectWorkPayListId);

    /**
     * 跟新 hp_project_work_pay 中合同总金额
     */
    public boolean updateWorkPayTotalContractAmount(@Param("contractAmountAll") BigDecimal contractAmountAll,@Param("workPayId") Long workPayId);

    public boolean updateItHasBeenInvoicedById(@Param("id") Long id, @Param("itHasBeenInvoiced") Integer itHasBeenInvoiced);


}




